package test1;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyServlet extends HttpServlet {

	@SuppressWarnings("unchecked")
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String login = req.getParameter("login");
		String pass = req.getParameter("pass");
		PrintWriter out = resp.getWriter();
		
		if("".equals(login) || "".equals(pass))
			out.println("Login or password is empty");
		else{
			out.println("<html><head><title>MyServlet</title></head>");
			out.println("<body><h1>Welcome " + login + ", your password is " + pass + "</h1><br>");
			Enumeration names = req.getHeaderNames();
			while(names.hasMoreElements()){
				String name = (String)names.nextElement();
				out.println(name + " : " + req.getHeader(name) + "<br>");
			}
			
			
			out.println("</body></html>");
		}
		
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(req, resp);
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -4872514260411207703L;

	
	
	
}
